package com.example.weixinpayment.controller;

import com.example.weixinpayment.entity.Product;
import com.example.weixinpayment.result.Result;
import com.example.weixinpayment.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: weixin-payment
 * @description: 产品控制器
 * @author: LiuZhuzheng
 * @create: 2021-12-28 19:35
 **/
@Api(tags = "商品管理")
@CrossOrigin
@RestController
@RequestMapping("/api/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @ApiOperation("获取商品列表")
    @GetMapping("/list")
    public Result listProduct(){
        List<Product> productList = productService.list();
        return Result.success().data("productList", productList);
    }
}
